|
In compiler theory, peephole optimization is a kind of optimization performed over a very small set of instructions in a segment of generated code. The set is called a "peephole" or a "window". It works by recognising sets of instructions that can be replaced by shorter or faster sets of instructions. ==Replacement rules== Common techniques applied in peephole optimization:〔Crafting a Compiler with C++, Fischer/LeBlanc〕 * Constant folding – Evaluate constant subexpressions in advance. * Strength reduction – Replace slow operations with faster equivalents. * Null sequences – Delete useless operations. * Combine Operations – Replace several operations with one equivalent. * Algebraic Laws – Use algebraic laws to simplify or reorder instructions. * Special Case Instructions – Use instructions designed for special operand cases. * Address Mode Operations – Use address modes to simplify code. There can, of course, be other types of peephole optimizations involving simplifying the target machine instructions, assuming that the target machine is known in advance. Advantages of a given architecture and instruction sets can be exploited in this case. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「peephole optimization」の詳細全文を読む スポンサード リンク
|